﻿#region Header
// Copyright 2007-2011, Jerónimo Milea
// 
// This file is part of NetJsWire.
// 
//     NetJsWire is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     NetJsWire is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with NetJsWire.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using NetJsWire.Lite.Converters;
using Newtonsoft.Json;

namespace NetJsWire.Lite.Widgets
{
    [Serializable]
    public class ToolConfig
    {
        private bool _stopEvent = true;

        /// <summary>
        ///   <b>Required.</b> The type of tool to create. By default, this assigns a CSS class of the form x-tool-&lt;tool-type&gt; to the resulting tool Element. Ext provides CSS rules, and an icon sprite containing images for the tool.
        /// </summary>
        [DefaultValue( ( string ) null )]
        [Description( "Required. The type of tool to create. By default, this assigns a CSS class of the form x-tool-&lt;tool-type&gt; to the resulting tool Element. Ext provides CSS rules, and an icon sprite containing images for the tool." )]
        [JsonProperty( "id", DefaultValueHandling = DefaultValueHandling.Ignore )]
        public string Id { get; set; }

        /// <summary>
        ///   <b>Required.</b> The function to call when clicked.
        /// </summary>
        [DefaultValue( ( string ) null )]
        [Description( "Required. The function to call when clicked." )]
        [JsonProperty( "handler", DefaultValueHandling = DefaultValueHandling.Ignore )]
        [JsonConverter( typeof( NotQuotedJsonStringConverter ) )]
        [Editor( typeof( MultilineStringEditor ), typeof( UITypeEditor ) )]
        public string Handler { get; set; }

        /// <summary>
        ///   Defaults to true. Specify as false to allow click event to propagate.
        /// </summary>
        [DefaultValue( true )]
        [Description( "Required. The function to call when clicked." )]
        [JsonProperty( "stopEvent", DefaultValueHandling = DefaultValueHandling.Ignore )]
        public bool StopEvent
        {
            get { return _stopEvent; }
            set { _stopEvent = value; }
        }

        /// <summary>
        ///   The scope in which to call the handler.
        /// </summary>
        [DefaultValue( ( string ) null )]
        [Description( "The scope in which to call the handler." )]
        [JsonProperty( "scope", DefaultValueHandling = DefaultValueHandling.Ignore )]
        [JsonConverter( typeof( NotQuotedJsonStringConverter ) )]
        public string Scope { get; set; }

        /// <summary>
        ///   A tip string.
        /// </summary>
        [DefaultValue( ( string ) null )]
        [Description( "A tip string." )]
        [JsonProperty( "qtip", DefaultValueHandling = DefaultValueHandling.Ignore )]
        public string Qtip { get; set; }

        /// <summary>
        ///   True to initially render hidden.
        /// </summary>
        [DefaultValue( false )]
        [Description( "True to initially render hidden." )]
        [JsonProperty( "hidden", DefaultValueHandling = DefaultValueHandling.Ignore )]
        public bool Hidden { get; set; }
    }
}
